package com.haixin.test.controller;

import com.haixin.test.utils.RedisUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

@RestController
@Slf4j
@RequestMapping("/redis")
public class RedisController {
    // redis中存储的过期时间60s
    private static int ExpireTime = 60;
    @Resource
    private RedisUtil redisUtil;
    @GetMapping("/setValue")
    public boolean redisSet(String key,String value){
        return redisUtil.set(key,value);
    }
    @RequestMapping("/expire")
    public boolean expire(String key){
        return redisUtil.expire(key,ExpireTime);
    }
}
